package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.Receipt;
import com.nbsaas.boot.project.api.domain.response.ReceiptResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
 * 收款单-实体对象转化成响应对象
 */

public class ReceiptResponseConvert implements Converter<ReceiptResponse, Receipt> {

    @Override
    public ReceiptResponse convert(Receipt source) {
        ReceiptResponse result = new ReceiptResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getCreator() != null) {
            result.setCreator(source.getCreator().getId());
        }

        try {
            if (source.getCreator() != null) {
                result.setCreatorName(source.getCreator().getName());
            }
        } catch (Exception ignored) {
        }

        if (source.getProject() != null) {
            result.setProject(source.getProject().getId());
        }

        try {
            if (source.getProject() != null) {
                result.setProjectName(source.getProject().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

